<?php

namespace Library\View;

class VirtualView extends \Library\View {

	private $_name;
	private $_context;

	public function __construct( $name, \Library\View $context ) {
		parent::__construct();
		$this->_name = $name;
		$this->_context = $context;
	}
	
	public function getView() {
		return $this->_context->getView() . '/' . $this->_name;
	}
	
	public function __call( $method, $args ) {
		if( !method_exists( $this->_context, $method ) ) {
			throw new \Exception( 'Unknown method ' . $method . ' in ' . get_class($this->_context) );
		}
		return call_user_func_array( array($this->_context, $method), $args );
	}
}
